package hypeerweb;

public class FindInsertionPoint extends FindExtremePoint {

	/**
	 * @param capNode
	 */
	public FindInsertionPoint(Node capNode) {
		super(capNode);
	}

	/**
	 * @return the smallest Node without a child in the HyPeerWeb
	 * @pre capNode is the actual capNode
	 * @post will return the insertionPoint
	 */
	public Node findExtremePointInPerfectCube() {
		return super.capNode.getFold();
	}

	/**
	 * @return the smallest Node without a child in the HyPeerWeb
	 * @pre capNode is the actual capNode
	 * @post will return the insertion Point
	 */
	public Node findExtremePointInImperfectWeb() {
		Node smallest = super.capNode;
		while (!smallest.getSmallerNeighborsWithoutChildren().isEmpty()) {
			smallest = smallest.getSmallerNeighborsWithoutChildren().first();
		}
		return smallest;
	}
}
